#include <iostream>

using namespace std;

void solve()
{
    int n; string s; cin >> n >> s;
    if(s[n - 1] == '1') 
    {
        cout << "NO" << endl;
        return;
    }
    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == '1')
        {
            for(int j = i; j < n; j++)
            {
                if(s[j] == '1') cnt++;
                else break;
            }
            if(cnt >= 2) 
            {
                cout << "YES" << endl;
                return;
            }
            else 
            {
                cout << "NO" << endl;
                return;
            }
        }
    }
    cout << "YES" << endl;
}

int main()
{
    int t; cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}